package com.mi9688.stream;

import com.mi9688.lambda.Student;

import java.util.Arrays;
import java.util.List;

public class Demo {
    public static void main(String[] args) {

        List<Student> students= Arrays.asList(new Student("张明",18),
                new Student("李黑",16),
                new Student("王红",17),
                new Student("张三",36),
                new Student("李四",27),
                new Student("刘备",56),
                new Student("关羽",47),
                new Student("张飞",49),
                new Student("张同",17),
                new Student("张良",41));
        //降序排序--查找姓张的--截取前三位
        students.stream().sorted((s1,s2)->s2.getAge()-s1.getAge())
                .filter(s->s.getName().startsWith("张"))
                .limit(3).forEach(System.out::println);
        System.out.println("-----------------------------------------------");

    }
}
